#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author: nigo
import plotly.graph_objects as go
import pandas as pd
# 数据
df = pd.read_csv('茅台.csv')
# 将交易日期'20200101'格式转化为标准日期
df['trade_date'] = pd.to_datetime(df['trade_date'],format="%Y%m%d")
# 轨迹
candle = go.Candlestick(x=df['trade_date'],open=df['open'],high=df['high'],
                        low=df['low'],close=df['close'],
                       increasing_line_color= 'red', decreasing_line_color= 'green')
# 画布
fig = go.Figure(candle)
# 更新样式
fig.update_layout(title='贵州茅台2020年日线图',xaxis_tickformat="%Y-%m",xaxis_dtick="M1")
# 显示画布
fig.show()
